var express = require('express');
var router = express.Router();
const pool = require('../pool.js');



// photo婚纱模块大标题
router.get ('/title',(req,res)=>{
    pool.query('select * from wed_photo_family',(err,result)=>{
        if (err) {
            next(err);
            return;
        }
        if(result.length>0){
             res.send(result)
        }else{
            res.send({
             code: 201,
             msg: "您请求的资源不存在！"  
            })
        }
    })
})






// 婚纱摄影详情页案例接口
router.get("/case/:pid", (req, res, next) => {
    let id=req.params.pid;
    console.log(id);
    var sql = "select * from wed_photo_case where eid=?";
    console.log(sql);
    pool.query(sql,[id], (err, result) => {
        console.log(result);
        if (err) {
            next(err);
            return;
        }
        if (result.length!== 0) {
            res.send({
                code: 200,
                result:result
            });
        } else {
            res.send({
                code: 201,
                msg: "您的请求资源不存在！"
            });
        }
    })
})





  
module.exports = router;